import request from '/@/utils/request';

// 用户列表
export function SysUserGetPagedList(params?: object) {
	return request({
		url: '/api/SysUser/GetPagedList',
		params,
	});
}

// 新增用户
export function SysUserCreate(data: any) {
	return request({
		url: 'api/SysUser/Create',
		method: 'post',
		data,
	});
}

// 编辑用户
export function SysUserUpdate(data: any, id: string) {
	return request({
		url: `api/SysUser/Update/${id}`,
		method: 'put',
		data,
	});
}

// 删除用户
export function SysUserDelete(id: string) {
	return request({
		url: `api/SysUser/Delete/${id}`,
		method: 'delete',
	});
}

//修改密码
export function SysUserChangePassword(data: any, id: string) {
	return request({
		url: `api/SysUser/ChangePassword/${id}`,
		method: 'put',
		data,
	});
}

/* 基于时间的一次性密码 */

// 查询系统用户的 Totp 配置
export function GetSysUserTotpConfig(id: string) {
	return request({
		url: `api/Totp/GetSysUserTotpConfig/${id}`,
	});
}

// 创建TOTP
export function CreateSecret(data: any) {
	return request({
		url: 'api/Totp/CreateSecret',
		method: 'post',
		data,
	});
}

// 清除totp
export function ClearSecret(id: string) {
	return request({
		url: `api/Totp/ClearSecret/${id}`,
		method: 'delete',
	});
}

//生成验证码
export function TotpGenerate() {
	return request({
		url: '/api/Totp/Generate',
	});
}

// 验证
export function TotpVerify(data: any) {
	return request({
		url: 'api/Totp/Verify',
		method: 'post',
		data,
	});
}
